﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>方向条件-按照岗位计算</title>
    <script type="text/javascript" src="../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/bootstrap.min.js"></script>
    
    <script src="../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../Scripts/config.js" type="text/javascript"></script>
    <script src="../Comm/Gener.js" type="text/javascript"></script>

    <script src="../Scripts/easyUI/jquery-1.8.0.min.js" type="text/javascript"></script>
    <link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    
    <base target="_self" />
    <script type="text/javascript">

        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }

        //初始化页面函数.....
        $(function () {

            var condType = GetQueryString("CondType");
            var fk_flow = GetQueryString("FK_Flow");
            var fk_mainNode = GetQueryString("FK_MainNode");
            var fk_Node = GetQueryString("FK_Node");
            var toNodeID = GetQueryString("ToNodeID");

            //初始化表格.
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=CondByDept_Init&CondType=" + condType + "&FK_Flow=" + fk_flow + "&FK_MainNode=" + fk_mainNode + "&FK_Node=" + fk_Node + "&ToNodeID=" + toNodeID + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {

                    if (data.indexOf('err@') == 0) {
                        $("#Msg").html("<font color=red>加载失败:<br>" + data + "</font> .");
                        return;
                    }

                    if (data.indexOf('url@') == 0) {
                        var url = data.replace('url@', '');
                        window.location.href = url;
                        return;
                    }

                    //转json.
                    data = JSON.parse(data);

                    var FK_Direction = fk_Node + "_" + toNodeID + "_0";

                    var link = "<a href=\"javascript:WinOpen('../Comm/RefFunc/Dot2DotStationModel.htm?EnsName=BP.WF.Template.Directions&EnName=BP.WF.Template.Direction&AttrKey=BP.WF.Template.DirectionStations&FK_Direction=" + FK_Direction + "&ShowWay=None')\" >设置/更改岗位(" + data.Nums + ")</a>";

                    //设置部门标签.
                    document.getElementById("depts").innerHTML = link ;

                    //设置操作员的身份.
                    document.getElementById("DDL_SpecOperWay").selectedIndex = data.SpecOperWay; // 操作员身份.
                    document.getElementById("TB_SpecOperPara").value = data.SpecOperPara; //参数.
                }
            });
        });

        //执行保存..
        function Save() {

            var condType = GetQueryString("CondType");
            var fk_flow = GetQueryString("FK_Flow");
            var fk_mainNode = GetQueryString("FK_MainNode");
            var fk_Node = GetQueryString("FK_Node");
            var toNodeID = GetQueryString("ToNodeID");

            var SpecOperWay = document.getElementById("DDL_SpecOperWay").selectedIndex;
            var SpecOperPara = document.getElementById("TB_SpecOperPara").value;

            var paras = "&DDL_SpecOperWay=" + SpecOperWay + "&TB_SpecOperPara=" + SpecOperPara;
            //alert(paras);

            //初始化表格.
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=CondByDept_Save&CondType=" + condType + "&FK_Flow=" + fk_flow + "&FK_MainNode=" + fk_mainNode + "&FK_Node=" + fk_Node + "&ToNodeID=" + toNodeID + paras + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {

                    if (data.indexOf('err@') == 0) {
                        $("#Msg").html("<font color=red>" + data + "</font>");
                        return;
                    }

                    if (data.indexOf('url@') == 0) {
                        var url = data.replace('url@', '');
                        window.location.href = url;
                        return;
                    }

                    alert(data);

                    //$("#Msg").html("<font color=green>" + data + "</font>");
                }
            });
        }

        //执行删除..
        function Delete() {

            if (window.confirm('您确定要删除吗？') == false)
                return;

            var condType = GetQueryString("CondType");
            var fk_flow = GetQueryString("FK_Flow");
            var fk_mainNode = GetQueryString("FK_MainNode");
            var fk_Node = GetQueryString("FK_Node");
            var toNodeID = GetQueryString("ToNodeID");

            //初始化表格.
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=CondByDept_Delete&CondType=" + condType + "&FK_Flow=" + fk_flow + "&FK_MainNode=" + fk_mainNode + "&FK_Node=" + fk_Node + "&ToNodeID=" + toNodeID + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {

                    if (data.indexOf('err@') == 0) {
                        $("#Msg").html("<font color=red>" + data + "</font>");
                        return;
                    }

                    if (data.indexOf('url@') == 0) {
                        var url = data.replace('url@', '');
                        window.location.href = url;
                        return;
                    }

                    alert(data);
                }
            });
        }

        function SetLab(c) {

            var selectIdx = c.value;

            var str = "";
            if (selectIdx == '0')
                str = "不需要任何参数";

            if (selectIdx == '1')
                str = "节点编号:(比如:101,102,)";

            if (selectIdx == '2')
                str = "表单字段:(比如:field1,field2,)";

            if (selectIdx == '3')
                str = "操作员编号:(比如:zhangsan,lisi,)";

            document.getElementById("LabInfo").innerHTML = str;
        }
    </script>
</head>
<body onkeypress="Esc();">

<form id="cc" > 


 <table style=" width:90%;">
 
  <tr> <th> 按照部门计算</th>  <th> <div id="depts"> </div> </th> </tr>
 <tr>
 <td> 指定的操作员:</td>

   <td>
   <select name="DDL_SpecOperWay" onchange="javascript:SetLab(this)" id="DDL_SpecOperWay" style="width:200px;"   >
	<option selected="selected" value="0">当前操作员</option>
	<option value="1">指定节点的操作员</option>
	<option value="2">指定表单字段作为操作员</option>
	<option value="3">指定操作员编号</option> 
    </select>

    </td>
 </tr>

 <tr>
 <td> <div id="LabInfo"></div> </td>
 <td><input name="TB_SpecOperPara" type="text" id="TB_SpecOperPara"   style="width:200px;" />&nbsp;&nbsp;多个值请用英文“逗号”来分隔。 </td>
 </tr>

 </table>

   <input type="button" value="保存" onclick="Save()"  />
   <input type="button" value="删除" onclick="Delete()"  />

  <div style=" text-align:left">
   <h4> &nbsp; &nbsp; &nbsp; &nbsp;帮助</h4>
   <ul>
   <li>格式: http://xxxx/xxx.xxx?s=sss , 此url返回小于等于0是不通过，大于等于1是通过。</li>
    <li>系统在调用此url时会向它传入4大参数:FK_Flow,FK_Node,WorkID,FID您通过这四个参数,您可以获得当前流程数据。</li>
    </ul>
   </div>
 
</form>

 <center><div id="Msg" /></center>

</body>
</html>

